# -*- coding: utf-8 -*-

import scrapy
from itcast.items import ItcastItem

class Itcast02Spider(scrapy.Spider):
    name = 'itcast02'
    allowed_domains = ['http://www.itcast.cn']
    start_urls = ['http://www.itcast.cn/channel/teacher.shtml']

    def parse(self, response):
        node_list = response.xpath("//div[@class='li_txt']")
        for node in node_list:
            item = ItcastItem()
            #xpath返回的是包含一个元素的列表
            item['name'] = node.xpath("./h3/text()").extract()[0]
            item['title'] = node.xpath("./h4/text()").extract()[0]
            item['info'] = node.xpath("./p/text()").extract()[0]
            #将获取的数据交给pipelines
            yield item
    
